<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../css/stylesite.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/styleleft.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/mystyle.css" />
<script type="text/javascript" src="../js/jquery-1.8.2.min.js"></script>
<style>
    a{color: blue;}
    a:hover{color: #f80c0c;}
</style>
	<script src="../js/jquery-1.8.2.min.js" ></script>
	<script src="../js/image.js" type="text/javascript"></script>
        <script src="../js/jsearch.js" type="text/javascript"></script>  
     <script type="text/javascript">
        var xmlHttp;
		function DetailContent(str)
		{
                if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                     		document.getElementById('rightcontent').innerHTML=xmlHttp.responseText;
                       }
                        else {
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                         document.getElementById("rightcontent").innerHTML='<img src="../Data/image_194154.gif"/>';
                    }
                }
                var url='Article_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?ID_show="+str;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
		} 
	</script>
   
   
<title>QUẢN LÝ BÀI VIẾT</title>
</head>

<body class="pagebody">
	<div id="wrapwebsite" >
             <?php 
            include('../element/header_adm.php');
                                ?>
            <div class="imagestop"></div>
            <div class="wrapmaincontent">
                <div id="maincontent">
                    <?php
                    if(!isset($_SESSION['user'])|| $_SESSION['user'][4]!='admin')
                        {      
                            echo '<p>Bạn không được quyền xem trang này</p>';
                             header ('location:/cfshop/home.php');
                        }
                        else
                        {
                              include_once 'Article_model.php';
                        $arr_Article=array();
                       // $arr_Article= getAllArticle();
                        $display=5;
                        if(isset($_GET['page'])&&(int)$_GET['page'])
                        {
                            $page=$_GET['page'];	
                        }
                        else 
                        {
                            $page=  getRecordArticle($display);
                        }
                        $start=(isset($_GET['start']) && (int)$_GET['start']>=0) ? $_GET['start'] :0;
                    ?>
                       
                    <div id="content" class="content">  
                        <div class="botcontentright">
                            <ul class="nav">
                                 <?php 
                        if($page>1)
                        {//hien thi so trang
                            $next=$start+$display;
                            $prev=$start-$display;
                            $current=($start/$display)+1;
                            //hien thi trang Previous
                            if($current!=1)
                            {
                                    echo "<li><a href='v_admArticle.php?start=$prev'>Previous</a></li>";
                            }
                            //Hien thi so link
                            for($i=1;$i<=$page;$i++)
                            {
                                    if($current!= $i){
                                            echo "<li><a href='v_admArticle.php?start=".($display*($i-1))."'>$i</a></li>";
                                            
                                            }
                                    else {
                                            echo '<li class="currentpage">'.$i.'</li>';	
                                    }

                            }
                            //hien thi trang Next
                            if($current!=$page)
                            {
                                    echo "<li><a href='v_admArticle.php?start=$next'>Next</a></li>";
                            }
                        }
			
                        ?>
                            </ul>
                        </div>
                    <div class="leftcontent">
                  <?php             
                            $arr_Article= getArticleSplit($start,$display);
                            foreach ($arr_Article as $article) {
//                                echo 'ID: '.$article[0].'<br>';
//                                echo 'Title: '.$article[1].'<br>';
//                                echo 'Author: '.$article[3].'<br>';
//                                echo 'CreatedDate: '.$article[4].'<br>';
                           // }  
                        ?>
                        <div class="rowtop"> <?php echo 'Ngày đăng: '.$article[4].'<br>';?></div>
                        <div class="row"><?php echo 'Tiêu đề: '.$article[1].'<br>';?></div>
                        <div class="row"><?php echo 'Tác giả: '.$article[3].'<br>';?></div>
<!--                        <div class="row"><?php // echo 'Ngày cập nhật: '.$article[5].'<br>';?></div>-->
                        <div class="row"><a class="link" onClick="DetailContent('<?php echo $article['0']?>')">Xem chi tiết >>></a></div>
                       <div class="row">
                       <?php						  		
                            if($article[6]==0)	
                                {  
                                         echo 'Trạng thái: <font color="#FFFFFF">Chưa duyệt</font> <br>'; 
                                         echo '<a href="Article_controller.php?ID_ArticleCheck='. $article[0].'"><img src="../images/1354025181_tick_64.png" width="20px" height="20px"  /></a>';             
                                }
                                 else
                                 {
                                  echo 'Trạng thái:<font color="#CE4300" size="+2"> Duyệt</font> <br>'; 
                                   echo '<a href="Article_controller.php?ID_ArticleUncheck='. $article[0].'"><img src="../images/1354027645_delete.png" width="20px" height="20px"  /></a>';             
                                 }                                           
				 echo '<a href="Article_controller.php?ID_Article='. $article[0].'"><img src="../images/1318498996_DeleteRed.ico" width="20px" height="20px"  /></a>';             
                     		
                                  ?>    
                              </div>
                        <?php } ?>
                    </div>
                    <div class="rightcontent" id="rightcontent"> 
                        
                    </div>
               <?php } ?>
                </div>
        </div>
    
</body>
</html>
